<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
#div1 {width:200px; height:200px; border:1px solid black;}
.box {background:red;}
</style>
<script>
function toRed()
{
	var oDiv=document.getElementById('div1');
	
	oDiv.className='box';
}
function toGreen()
{
	var oDiv=document.getElementById('div1');
	
	oDiv.style.background='green';
}
</script>
</head>

<body>
<input type="button" value="变红" onclick="toRed()" />
<input type="button" value="变绿" onclick="toGreen()" />
<div id="div1"></div>
</body>
</html>
